#ifndef MENU_H
#define MENU_H
#include "system.h"

namespace win
{
	
	/* Menu class encapsulates HMENU 
	   A menu class consists of Items.  Each item
       has properties that can be set.  The can be
       accessed via the SetItemXXX methods. These
       methods takes the command id as parameter.
       Some Items are SubMenu (i.e. they have their own items).
       To create a submenu, first append an item and then call SetItemSubMenu 
 	*/
	class Menu
	{
		protected:
			HMENU _handle;
			Menu(); // menus cannot be created without context
		public:
			Menu(HMENU _handle);
			// create as window main menu
			Menu(HWND window_handle);
			Menu ChildByCommand(const int CommandId);			
			Menu SubMenuAt(const int pos);
			HMENU GetHandle() const
				{ return _handle; }
			// remove all the menu items in the menu
			void RemoveAllMenus();
			// the number of child menus this menu has
			int Count();
			void EnableMenuItemById(unsigned int id, bool enable);
			int AppendItem(const int CommandId, const char * Text);
			int AppendItem(const int CommandId, const char * Text, void * data);
			int AppendSeperator();
			// menu item properties
			void * GetItemData(const int CommandId);
			void SetItemSubMenu(const int CommandId, const Menu& m);
			
//			void GetMenuItemById(unsigned int id, MenuItem &result);
		private:
	};
	
	class PopupMenu : public Menu
	{
		public:
			PopupMenu();
			void Track(int x, int y, HWND receiver);
			// call destroy if the menu is not used after its created
			void Destroy();
	};


}

#endif // MENU_H

